package de.hwrberlin.remo.diagram.providers;

import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Map;
import java.util.Set;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.ENamedElement;
import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.tooling.runtime.providers.DiagramElementTypeImages;
import org.eclipse.gmf.tooling.runtime.providers.DiagramElementTypes;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;

import de.hwrberlin.remo.diagram.edit.parts.AndRuleEditPart;
import de.hwrberlin.remo.diagram.edit.parts.BooleanFactEditPart;
import de.hwrberlin.remo.diagram.edit.parts.ImplicationEditPart;
import de.hwrberlin.remo.diagram.edit.parts.KnowledgeBaseEditPart;
import de.hwrberlin.remo.diagram.edit.parts.LinksFromFactsEditPart;
import de.hwrberlin.remo.diagram.edit.parts.LinksFromRulesEditPart;
import de.hwrberlin.remo.diagram.edit.parts.OrRuleEditPart;
import de.hwrberlin.remo.diagram.part.RemoDiagramEditorPlugin;
import de.hwrberlin.remo.model.RemoModelPackage;

/**
 * @generated
 */
public class RemoElementTypes {

	/**
	 * @generated
	 */
	private RemoElementTypes() {
	}

	/**
	 * @generated
	 */
	private static Map<IElementType, ENamedElement> elements;

	/**
	 * @generated
	 */
	private static DiagramElementTypeImages elementTypeImages = new DiagramElementTypeImages(
			RemoDiagramEditorPlugin.getInstance()
					.getItemProvidersAdapterFactory());

	/**
	 * @generated
	 */
	private static Set<IElementType> KNOWN_ELEMENT_TYPES;

	/**
	 * @generated
	 */
	public static final IElementType KnowledgeBase_1000 = getElementType("de.hwrberlin.remo.diagram.KnowledgeBase_1000"); //$NON-NLS-1$
	/**
	 * @generated
	 */
	public static final IElementType AndRule_2004 = getElementType("de.hwrberlin.remo.diagram.AndRule_2004"); //$NON-NLS-1$
	/**
	 * @generated
	 */
	public static final IElementType Implication_2007 = getElementType("de.hwrberlin.remo.diagram.Implication_2007"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType BooleanFact_2005 = getElementType("de.hwrberlin.remo.diagram.BooleanFact_2005"); //$NON-NLS-1$
	/**
	 * @generated
	 */
	public static final IElementType OrRule_2006 = getElementType("de.hwrberlin.remo.diagram.OrRule_2006"); //$NON-NLS-1$
	/**
	 * @generated
	 */
	public static final IElementType LinksFromRules_4005 = getElementType("de.hwrberlin.remo.diagram.LinksFromRules_4005"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static final IElementType LinksFromFacts_4006 = getElementType("de.hwrberlin.remo.diagram.LinksFromFacts_4006"); //$NON-NLS-1$

	/**
	 * @generated
	 */
	public static ImageDescriptor getImageDescriptor(ENamedElement element) {
		return elementTypeImages.getImageDescriptor(element);
	}

	/**
	 * @generated
	 */
	public static Image getImage(ENamedElement element) {
		return elementTypeImages.getImage(element);
	}

	/**
	 * @generated
	 */
	public static ImageDescriptor getImageDescriptor(IAdaptable hint) {
		return getImageDescriptor(getElement(hint));
	}

	/**
	 * @generated
	 */
	public static Image getImage(IAdaptable hint) {
		return getImage(getElement(hint));
	}

	/**
	 * Returns 'type' of the ecore object associated with the hint.
	 * 
	 * @generated
	 */
	public static ENamedElement getElement(IAdaptable hint) {
		Object type = hint.getAdapter(IElementType.class);
		if (elements == null) {
			elements = new IdentityHashMap<IElementType, ENamedElement>();

			elements.put(KnowledgeBase_1000,
					RemoModelPackage.eINSTANCE.getKnowledgeBase());

			elements.put(BooleanFact_2005,
					RemoModelPackage.eINSTANCE.getBooleanFact());

			elements.put(AndRule_2004, RemoModelPackage.eINSTANCE.getAndRule());

			elements.put(Implication_2007,
					RemoModelPackage.eINSTANCE.getImplication());

			elements.put(OrRule_2006, RemoModelPackage.eINSTANCE.getOrRule());

			elements.put(LinksFromRules_4005,
					RemoModelPackage.eINSTANCE.getLinksFromRules());

			elements.put(LinksFromFacts_4006,
					RemoModelPackage.eINSTANCE.getLinksFromFacts());
		}
		return (ENamedElement) elements.get(type);
	}

	/**
	 * @generated
	 */
	private static IElementType getElementType(String id) {
		return ElementTypeRegistry.getInstance().getType(id);
	}

	/**
	 * @generated
	 */
	public static boolean isKnownElementType(IElementType elementType) {
		if (KNOWN_ELEMENT_TYPES == null) {
			KNOWN_ELEMENT_TYPES = new HashSet<IElementType>();
			KNOWN_ELEMENT_TYPES.add(KnowledgeBase_1000);
			KNOWN_ELEMENT_TYPES.add(BooleanFact_2005);
			KNOWN_ELEMENT_TYPES.add(AndRule_2004);
			KNOWN_ELEMENT_TYPES.add(Implication_2007);
			KNOWN_ELEMENT_TYPES.add(OrRule_2006);
			KNOWN_ELEMENT_TYPES.add(LinksFromRules_4005);
			KNOWN_ELEMENT_TYPES.add(LinksFromFacts_4006);
		}
		return KNOWN_ELEMENT_TYPES.contains(elementType);
	}

	/**
	 * @generated
	 */
	public static IElementType getElementType(int visualID) {
		switch (visualID) {
		case KnowledgeBaseEditPart.VISUAL_ID:
			return KnowledgeBase_1000;
		case BooleanFactEditPart.VISUAL_ID:
			return BooleanFact_2005;
		case AndRuleEditPart.VISUAL_ID:
			return AndRule_2004;
		case ImplicationEditPart.VISUAL_ID:
			return Implication_2007;
		case OrRuleEditPart.VISUAL_ID:
			return OrRule_2006;
		case LinksFromRulesEditPart.VISUAL_ID:
			return LinksFromRules_4005;
		case LinksFromFactsEditPart.VISUAL_ID:
			return LinksFromFacts_4006;
		}
		return null;
	}

	/**
	 * @generated
	 */
	public static final DiagramElementTypes TYPED_INSTANCE = new DiagramElementTypes(
			elementTypeImages) {

		/**
		 * @generated
		 */
		@Override
		public boolean isKnownElementType(IElementType elementType) {
			return de.hwrberlin.remo.diagram.providers.RemoElementTypes
					.isKnownElementType(elementType);
		}

		/**
		 * @generated
		 */
		@Override
		public IElementType getElementTypeForVisualId(int visualID) {
			return de.hwrberlin.remo.diagram.providers.RemoElementTypes
					.getElementType(visualID);
		}

		/**
		 * @generated
		 */
		@Override
		public ENamedElement getDefiningNamedElement(
				IAdaptable elementTypeAdapter) {
			return de.hwrberlin.remo.diagram.providers.RemoElementTypes
					.getElement(elementTypeAdapter);
		}
	};
}